package com.lagou.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @author Roger
 * @date 2020/8/20 21:48
 * @description
 */
@Controller
public class FileUploadController {

    /*@RequestMapping(value = "/fileUpload")
    public String upload(String fileName, MultipartFile file) throws IOException {
        System.out.println(fileName);
        String originalFilename = file.getOriginalFilename();
        file.transferTo(new File("C:/java" + originalFilename));
        return "success";
    }*/

    @RequestMapping("/fileUpload")
    public String fileUpload(String username, MultipartFile filePic) throws IOException {
        System.out.println(username);
        String originalFilename = filePic.getOriginalFilename();
        filePic.transferTo(new File("c:/java/" + originalFilename));
        return "success";
    }


    @RequestMapping("/error")
    public String error() {
        int i = 1 / 0;
        return "success";
    }
}
